import request from '@/utils/request'

export function UpstreamList(query) {
  return request({
    url: '/kong/upstream/list',
    method: 'get',
    params: query
  })
}

export function addUpstream(data) {
  return request({
    url: '/kong/upstream/add',
    method: 'post',
    data: data
  })
}

export function updateUpstream(data) {
  return request({
    url: '/kong/upstream/update/'+data.id,
    method: 'post',
    data: data
  })
}

export function deleteUpstream(id) {
  return request({
    url: '/kong/upstream/delete/'+id,
    method: 'post',
  })
}

export function getUpstreamById(id) {
  return request({
    url: '/kong/upstream/get/'+id,
    method: 'get',
  })
}

export function getTargetByUpstreamId(id) {
  return request({
    url: '/kong/upstream/target/'+id,
    method: 'get',
  })
}

export function addTargetToUpstreamId(upstreamId,data) {
  return request({
    url: '/kong/upstream/target/add/'+upstreamId,
    method: 'post',
    data: data
  })
}

export function deleteTargetFromUpstreamId(upstreamId,id) {
  return request({
    url: '/kong/upstream/target/delete/'+upstreamId+"/"+id,
    method: 'post',
  })
}